/*

    Copyright 2011 Cuong Le <metacuong@gmail.com>
  
    This package is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This package is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this package; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

*/

#ifndef DROPRESTAPI_H
#define DROPRESTAPI_H

#include "oauth.h"

#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
#include <QByteArray>

#define REQUEST_TOKEN_URL               "http://api.dropbox.com/0/oauth/request_token"
#define REQUEST_ACCESS_TOKEN            "https://api.dropbox.com/1/oauth/access_token"
#define TRUSTED_ACCESS_TOKEN_URL        "http://api.dropbox.com/0/token"
#define FILES_URL                       "http://api.dropbox.com/0/files/dropbox"
#define FILES_TRANSFER_URL              "https://api-content.dropbox.com/0/files/dropbox"

#define FILE_DELETE_URL                 "https://api.dropbox.com/0/fileops/delete"
#define CREATE_FOLDER_URL               "https://api.dropbox.com/0/fileops/create_folder"
#define FILE_MOVE_URL                   "https://api.dropbox.com/0/fileops/move"
#define FILE_COPY_URL                   "https://api.dropbox.com/0/fileops/copy"
#define SHARES_URL                      "https://api.dropbox.com/0/shares"

#define METADATA_URL                    "https://api.dropbox.com/0/metadata/dropbox"
#define ACCOUNT_URL                     "https://api.dropbox.com/0/account"
#define ACCOUNT_INFO_URL                "https://api.dropbox.com/1/account/info"

class QByteArray;

class DropRestAPI
{
public:
    DropRestAPI();
    ~DropRestAPI();

    QNetworkRequest request_token();
    QNetworkRequest user_authentication(QString, QString);
    QNetworkRequest request_access_token();

    QNetworkRequest root_dir(const QString&);

    void oauth_request_token_reply_process(QNetworkReply*);
    void oauth_user_authentication_reply_process(QNetworkReply*);

    QNetworkRequest file_transfer(QString filename, QString dropbox_folder, QString boundaryStr);
    QNetworkRequest file_transfer_download(QString dropbox_filepath);

    QNetworkRequest __delete(QString dropbox_filepath);
    QNetworkRequest __create(QString dropbox_filepath);
    QNetworkRequest __move(QString path_source, QString path_destination);
    QNetworkRequest __copy(QString path_source, QString path_destination);
    QNetworkRequest __shares(QString dropbox_filepath);

    QNetworkRequest accountinfo();

    OAuth *oauth;

};

#endif // DROPRESTAPI_H
